package common.service.base.common;

import common.service.contants.MobileConfig;
import common.service.util.BeanToMapUtil;

import java.util.HashMap;
import java.util.Map;


public class RespVo{

	private String status;
	private String msg;
	private Map<String,Object> data;
	public RespVo(){
		status= MobileConfig.MOBILE_RESP_STATUS_SUCCESS;
		msg=MobileConfig.MOBILE_RESP_MSG_SUCCESS;
		this.data = new HashMap<String,Object>();
	}
	public RespVo(Object object){
		status= MobileConfig.MOBILE_RESP_STATUS_SUCCESS;
		msg=MobileConfig.MOBILE_RESP_MSG_SUCCESS;
		setMapData(object);
	}


	public RespVo(String status,String msg){
		this.status=status;
		this.msg=msg;
		this.data = new HashMap<String,Object>();

	}

	/***
	 * 设置返回数据
	 * @param name
	 * @param value
	 */
	public void setValue(String name,Object value){
		if(value ==null){
			value = "";
		}
		data.put(name, value);
	}
	
	/***
	 * 获取数据
	 * @param name
	 * @return Object
	 */
	public Object getValue(String name){
		return data.get(name);
	}

	public Map<String,Object> getData(){
		return this.data;
	}

	public void  setMapData(Object object){
		Map<String, Object> stringObjectMap = BeanToMapUtil.convertBean(object);
		this.data =stringObjectMap;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public void setData(Map<String, Object> data) {
		this.data = data;
	}
}
